package tech.aistar.service.impl;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import tech.aistar.entity.SeeRoomTrend;
import tech.aistar.mapper.SeeRoomTrendMapper;
import tech.aistar.service.ISeeRoomTrendService;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class SeeRoomTrendImpl implements ISeeRoomTrendService {
    @Autowired
    private SeeRoomTrendMapper seeRoomTrendMapper;
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @Override
    public List<SeeRoomTrend> selectAll() {
        return seeRoomTrendMapper.selectAll();
    }

    @Override
    public void insert(SeeRoomTrend seeRoomTrend) {
seeRoomTrendMapper.insert(seeRoomTrend);
    }

    @Override
    public void updateByPrimaryKey(SeeRoomTrend seeRoomTrend) {
seeRoomTrendMapper.updateByPrimaryKey(seeRoomTrend);
    }

    @Override
    public SeeRoomTrend selectByHouseId(Integer house_id, Date see_time) {
       return seeRoomTrendMapper.selectByHouseId(house_id,see_time);
    }

    @Override
    public void deleteByPrimaryKey(Integer id) {
seeRoomTrendMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void updateByHouseId(Integer see_count,Date see_time,Integer house_id) {
        seeRoomTrendMapper.updateByHouseId(see_count,house_id,see_time);
    }

    @Override
    public List<SeeRoomTrend> selectThree() {
        return seeRoomTrendMapper.selectThree();
    }

    @Override
    public void save2Rbm(String uname) {
        Map<String,Object> dataMaps = new HashMap<>();
        dataMaps.put("house_id",uname);
        rabbitTemplate.convertAndSend("j08_exch",null,dataMaps);
    }
}
